/**
 * 
 */
package com.xpec.c4.game.login.async2;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ms.service.module.account.Account;
import com.ms.service.module.account.db.AccountDAO;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.service.module.task.TaskAsyncCommand;

/**
 * @author TW15010
 *
 */
public class DoAfterLoadAccountAsync extends TaskAsyncCommand {
	/** log4j object */
	private static final Log log = LogFactory.getLog(DoAfterLoadAccountAsync.class);

	/**
	 * 要載入的 account guid
	 */
	private GUID loadAccountId;

	/**
	 * 從 db 載入的 account data
	 */
	private Account loadAccount;

	/**
	 * @param loadAccountId
	 */
	public void initial(GUID loadAccountId) {
		this.loadAccountId = loadAccountId;
		this.key = loadAccountId;
	}

	@Override
	public void asyncExecute() throws Exception {
		// TODO kevin jb verify
		loadAccount = AccountDAO.loadAccountFromRedis(loadAccountId);

		if (loadAccount == null) {
			if (log.isErrorEnabled()) {
				log.error(this.getClass().getSimpleName() + "load account data fail, a:" + loadAccountId);
			}
		}
	}

	@Override
	public void execute() throws Exception {
	}

	public GUID getLoadAccountId() {
		return loadAccountId;
	}

	public void setLoadAccountId(GUID loadAccountId) {
		this.loadAccountId = loadAccountId;
	}

	public Account getLoadAccount() {
		return loadAccount;
	}
}
